package cn.italkcloud.cph.entity;

import cn.italkcloud.cph.entity.dto.vos.CdrDTO;
import cn.italkcloud.cph.utils.StringUtil;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;

/**
 * <p>
 * VOS通话数据报表-自定时间范围内的数据
 * </p>
 *
 * @author dominate
 * @since 2025-04-30
 */
@Getter
@Setter
@Accessors(chain = true)
@ToString
@TableName("report_vos_cdr")
public class ReportVosCdr implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    @TableField("server_id")
    private Integer serverId;

    /**
     * 最后请求数据的ID
     */
    @TableField("latest_vos_cdr_id")
    private Integer latestVosCdrId;

    /**
     * 主叫网关
     */
    @TableField("caller_vos_gateway_id")
    private String callerVosGatewayId;

    /**
     * 被叫网关
     */
    @TableField("callee_vos_gateway_id")
    private String calleeVosGatewayId;

    /**
     * VOS结算账户
     */
    @TableField("vos_agent_account")
    private String vosAgentAccount;


    /**
     * VOS用户账户
     */
    @TableField("vos_customer_account")
    private String vosCustomerAccount;


    /**
     * 开始时间范围
     */
    @TableField("start_time")
    private Date startTime;

    /**
     * 结束时间范围
     */
    @TableField("end_time")
    private Date endTime;

    /**
     * 总通话时长
     */
    @TableField("total_duration")
    private Integer totalDuration;

    /**
     * 最大通话时长
     */
    @TableField("max_duration")
    private Integer maxDuration;

    /**
     * 最小通话时长
     */
    @TableField("min_duration")
    private Integer minDuration;

    /**
     * 通话总计次数
     */
    @TableField("total_count")
    private Integer totalCount;

    /**
     * 主叫结束通话次数
     */
    @TableField("total_end_caller_count")
    private Integer totalEndCallerCount;

    /**
     * 被叫结束通话次数
     */
    @TableField("total_end_callee_count")
    private Integer totalEndCalleeCount;

    /**
     * 服务器结束通话次数
     */
    @TableField("total_end_server_count")
    private Integer totalEndServerCount;

    /**
     * 应答次数
     */
    @TableField("answer_count")
    private Integer answerCount;

    /**
     * 应答主叫结束通话次数
     */
    @TableField("answer_end_caller_count")
    private Integer answerEndCallerCount;

    /**
     * 应答被叫结束通话次数
     */
    @TableField("answer_end_callee_count")
    private Integer answerEndCalleeCount;

    /**
     * 应答服务器结束通话次数
     */
    @TableField("answer_end_server_count")
    private Integer answerEndServerCount;

    @TableField("create_time")
    private Date createTime;

    @TableField("update_time")
    private Date updateTime;

    public ReportVosCdr() {
    }

    public ReportVosCdr(CdrDTO cdr) {
        this.latestVosCdrId = cdr.getId();
        this.callerVosGatewayId = StringUtil.isBlank(cdr.getCallergatewayid()) ? "" : cdr.getCallergatewayid();
        this.calleeVosGatewayId = StringUtil.isBlank(cdr.getCalleegatewayid()) ? "" : cdr.getCalleegatewayid();
        this.vosAgentAccount = StringUtil.isBlank(cdr.getAgentaccount()) ? "" : cdr.getAgentaccount();
        this.vosCustomerAccount = StringUtil.isBlank(cdr.getCustomeraccount()) ? "" : cdr.getCustomeraccount();
        // 标记未被设置
        this.minDuration = -1;
        this.maxDuration = -1;
        this.serverId = 0;
        this.totalDuration = 0;
        this.totalCount = 0;
        this.totalEndCallerCount = 0;
        this.totalEndCalleeCount = 0;
        this.totalEndServerCount = 0;
        this.answerCount = 0;
        this.answerEndCallerCount = 0;
        this.answerEndCalleeCount = 0;
        this.answerEndServerCount = 0;
    }
}
